package main

import (
	"log"
	"net/http"
	"traffic/controller"
	"traffic/system"
)

func init() {
	system.InitDb()
	system.InitRedis()
	route()
	log.Println("Service started")
}

func route() {
	http.HandleFunc("/", controller.Index)
	http.HandleFunc("/ad", controller.Showads)
	http.HandleFunc("/clscache", controller.Clscache)
	http.HandleFunc("/click.js", controller.Click)

}

func main() {
	// 启动静态文件服务
	log.SetFlags(log.Lshortfile | log.LstdFlags)
	http.Handle("/views/", http.StripPrefix("/views/", http.FileServer(http.Dir("views"))))
	http.ListenAndServe(":80", nil)
}
